package javagame;

import java.awt.Color;
import java.awt.DisplayMode;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.RenderingHints;

import javax.swing.ImageIcon;
import javax.swing.JFrame;

/**
 * @author Sabre Runner
 *
 */
@SuppressWarnings("serial")
public class Main extends JFrame
{
	@SuppressWarnings("unused")
	private Screen screen;
	private Image background;
	private Image picture;
	private boolean loaded;
	
	// TODO Write constructor
	Main()
	{
	}

	public static void Error(String error)
	{
		System.err.println(error);
	}
	
	public static void main(String[] args)
	{
		DisplayMode displayMode = new DisplayMode(1366, 768, 32, 60);
		Main main = new Main();
		main.run(displayMode);
	}
	
	public void run(DisplayMode displayMode)
	{
		setBackground(Color.PINK);
		setForeground(Color.WHITE);
		setFont(new Font("Arial", Font.PLAIN, 24));
		loaded = false;
		
		Screen screen = new Screen();
		
		try
		{
			screen.setFullScreen(displayMode, this);
			LoadPictures();
			Thread.sleep(5000);
		}
		catch (Exception exception)
		{
			Error("Screen configuration failed.");
		}
		finally
		{
			screen.restoreScreen();
		}
	}

	private void LoadPictures()
	{
		background = new ImageIcon("001.jpg").getImage();
		picture = new ImageIcon("1.jpg").getImage();
		loaded = true;
		repaint();
	}

	@Override
	public void paint(Graphics graphics)
	{
		if (graphics instanceof Graphics2D)
		{
			Graphics2D graphics2d = (Graphics2D)graphics;
			graphics2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, 
										RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
		}
		
		if (loaded)
		{
			graphics.drawImage(background, 0, 0, 1366, 768, null);
			graphics.drawImage(picture, 50, 50, 200, 300, null);
		}
	}
}
